package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SDingdan;
import com.ruoyi.system.service.ISDingdanService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 停车场订单Controller
 * 
 * @author ruoyi
 * @date 2024-12-27
 */
@Controller
@RequestMapping("/system/dingdan")
public class SDingdanController extends BaseController
{
    private String prefix = "system/dingdan";

    @Autowired
    private ISDingdanService sDingdanService;

    @RequiresPermissions("system:dingdan:view")
    @GetMapping()
    public String dingdan()
    {
        return prefix + "/dingdan";
    }

    /**
     * 查询停车场订单列表
     */
    @RequiresPermissions("system:dingdan:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SDingdan sDingdan)
    {
        startPage();
        List<SDingdan> list = sDingdanService.selectSDingdanList(sDingdan);
        return getDataTable(list);
    }

    /**
     * 导出停车场订单列表
     */
    @RequiresPermissions("system:dingdan:export")
    @Log(title = "停车场订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SDingdan sDingdan)
    {
        List<SDingdan> list = sDingdanService.selectSDingdanList(sDingdan);
        ExcelUtil<SDingdan> util = new ExcelUtil<SDingdan>(SDingdan.class);
        return util.exportExcel(list, "停车场订单数据");
    }

    /**
     * 新增停车场订单
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存停车场订单
     */
    @RequiresPermissions("system:dingdan:add")
    @Log(title = "停车场订单", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SDingdan sDingdan)
    {
        return toAjax(sDingdanService.insertSDingdan(sDingdan));
    }

    /**
     * 修改停车场订单
     */
    @RequiresPermissions("system:dingdan:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        SDingdan sDingdan = sDingdanService.selectSDingdanById(id);
        mmap.put("sDingdan", sDingdan);
        return prefix + "/edit";
    }

    /**
     * 修改保存停车场订单
     */
    @RequiresPermissions("system:dingdan:edit")
    @Log(title = "停车场订单", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SDingdan sDingdan)
    {
        return toAjax(sDingdanService.updateSDingdan(sDingdan));
    }

    /**
     * 删除停车场订单
     */
    @RequiresPermissions("system:dingdan:remove")
    @Log(title = "停车场订单", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sDingdanService.deleteSDingdanByIds(ids));
    }
}
